package pl.polidea.imf.blackberry.ui;

import pl.polidea.imf.blackberry.service.IMFService;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class ReportIssuePopUpScreen extends PopupScreen {
	
	EditField message;
	
	ButtonField okButton;
	ButtonField closeButton;
	
	public ReportIssuePopUpScreen(final UiController controller) {
		super(new VerticalFieldManager(), Manager.VERTICAL_SCROLL);
		message = new EditField("Issue description: ", "");
		
		okButton = new ButtonField("Save");
		closeButton = new ButtonField("Close");

		add(message);
		
		add(okButton);
		add(closeButton);

		okButton.setChangeListener(new FieldChangeListener() {

			public void fieldChanged(Field field, int context) {
				IMFService.getInstance().uiRequestedIssueReport(message.getText());
				controller.closeIssueReportPopUp();
			}

		});

		closeButton.setChangeListener(new FieldChangeListener() {

			public void fieldChanged(Field field, int context) {
				controller.closeIssueReportPopUp();
			}

		});
		
	}
	
}
